package com.example.materialviewpagerdemo;

import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.azeui.AzeUIButton;
import com.example.azeui.AzeUIEditText;
import com.example.materialviewpagerdemo.util.SPHelper;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LoginActivity extends AppCompatActivity {
    @BindView(R.id.username)
    AzeUIEditText username;
    @BindView(R.id.psw)
    AzeUIEditText psw;
    @BindView(R.id.login)
    AzeUIButton login;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_activity);
        ButterKnife.bind(this);
        SPHelper spHelper=new SPHelper(this,"login");
        if(spHelper.getBoolean("isFirst")){
            startActivity(new Intent(LoginActivity.this,MainActivity.class));
            LoginActivity.this.finish();
        }
        psw.setHint("请输入密码");
        psw.setEditType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD);
        psw.setImage(R.drawable.ic_lock_outline_black_24dp);
        username.setImage(R.drawable.ic_perm_identity_black_24dp);
        login.setListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (username.getText().equals("admin")&&psw.getText().equals("apple")){
                    SPHelper.VauleMap vauleMap=new SPHelper.VauleMap("isFirst",true);
                    spHelper.putVaule(vauleMap);
                    startActivity(new Intent(LoginActivity.this,MainActivity.class));
                    LoginActivity.this.finish();
                }
            }
        });
    }
}
